import Mock from 'mockjs';
import '@/mock/extend';

Mock.mock('/login', 'post', ({ body }) => {
  let result = {};
  const { name, password } = JSON.parse(body);

  if (name !== 'admin' || password !== 'admin') {
    result.code = -1;
    result.message = '账户名或密码错误（admin/admin)';
  } else {
    result.code = 200;
    result.message = '管理员您好，欢迎回来';
    result.data = {};
    result.data.user = {
      id: 10000,
      name: '管理员',
      username: 'admin',
      region: 510000,
      level: 'province',
      levelPath: '/510000/',
      regionName: '四川',
      roles: ['sysadmin'],
      avatar:
        'https://gw.alipayobjects.com/zos/rmsportal/WhxKECPNujWoWEFNdnJE.png'
    };
  }
  return result;
});
